package com.apps.epocket.stripes;

import able.stripes.JSP;
import com.apps.epocket.manager.PengiklananManager;
import com.apps.epocket.model.Pengiklanan;
import com.google.inject.Inject;
import java.util.List;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;

@UrlBinding("/welcome")
public class WelcomeActionBean extends BaseActionBean { 
    
    private List<Pengiklanan> senaraiIklan;
    
    @Inject PengiklananManager pengiklananManager;
    
    private String textSearch;
    
    private String kategorySearch;
    
    private String locationSearch;
    
    @DefaultHandler
    public Resolution welcome() {
        senaraiIklan = pengiklananManager.senaraiPengiklananByStatus(StatusConstraints.ACTIVE_ADS);
        return new JSP("home.jsp");
    }
    
    public Resolution search() {
        senaraiIklan = pengiklananManager.senaraiPengiklananByKategori(kategorySearch, textSearch, locationSearch);
        return new JSP("home.jsp");
    }

    public List<Pengiklanan> getSenaraiIklan() {
        return senaraiIklan;
    }

    public void setSenaraiIklan(List<Pengiklanan> senaraiIklan) {
        this.senaraiIklan = senaraiIklan;
    }

    public String getKategorySearch() {
        return kategorySearch;
    }

    public void setKategorySearch(String kategorySearch) {
        this.kategorySearch = kategorySearch;
    }

    public String getTextSearch() {
        return textSearch;
    }

    public void setTextSearch(String textSearch) {
        this.textSearch = textSearch;
    }

    public String getLocationSearch() {
        return locationSearch;
    }

    public void setLocationSearch(String locationSearch) {
        this.locationSearch = locationSearch;
    }
}
